#include "delge_squirrelgraphics_texture.h"

void s_Graphics_Texture_RegisterFunctions (HSQUIRRELVM v)
{
	SquirrelVM::CreateFunctionGlobal(s_Graphics_Texture_GetWidth,		_SC("Texture_GetWidth"),				_SC("*"));
	SquirrelVM::CreateFunctionGlobal(s_Graphics_Texture_GetHeight,		_SC("Texture_GetHeight"),				_SC("*"));
	SquirrelVM::CreateFunctionGlobal(s_Graphics_Texture_GetWidthPow2,	_SC("Texture_GetWidthPow2"),			_SC("*"));
	SquirrelVM::CreateFunctionGlobal(s_Graphics_Texture_GetHeightPow2,	_SC("Texture_GetHeightPow2"),			_SC("*"));
	SquirrelVM::CreateFunctionGlobal(s_Graphics_Texture_GetUOffset,		_SC("Texture_GetUOffset"),				_SC("*"));
	SquirrelVM::CreateFunctionGlobal(s_Graphics_Texture_GetVOffset,		_SC("Texture_GetVOffset"),				_SC("*"));
}

SQInteger s_Graphics_Texture_GetWidth (HSQUIRRELVM v)
{
	const SQChar			*sTextureName;

	sq_getstring			(v, 2, &sTextureName);

	Texture *pTexture = ResourceManager<Texture>::GetResource(string(sTextureName));

	sq_pushinteger			(v, pTexture->GetWidth());

	return 1;
}

SQInteger s_Graphics_Texture_GetHeight (HSQUIRRELVM v)
{
	const SQChar			*sTextureName;

	sq_getstring			(v, 2, &sTextureName);

	Texture *pTexture = ResourceManager<Texture>::GetResource(string(sTextureName));

	sq_pushinteger			(v, pTexture->GetHeight());

	return 1;
}

SQInteger s_Graphics_Texture_GetWidthPow2 (HSQUIRRELVM v)
{
	const SQChar			*sTextureName;

	sq_getstring			(v, 2, &sTextureName);

	Texture *pTexture = ResourceManager<Texture>::GetResource(string(sTextureName));

	sq_pushinteger			(v, pTexture->GetWidthPow2());

	return 1;
}

SQInteger s_Graphics_Texture_GetHeightPow2 (HSQUIRRELVM v)
{
	const SQChar			*sTextureName;

	sq_getstring			(v, 2, &sTextureName);

	Texture *pTexture = ResourceManager<Texture>::GetResource(string(sTextureName));

	sq_pushinteger			(v, pTexture->GetHeightPow2());

	return 1;
}

SQInteger s_Graphics_Texture_GetUOffset (HSQUIRRELVM v)
{
	const SQChar			*sTextureName;

	sq_getstring			(v, 2, &sTextureName);

	Texture *pTexture = ResourceManager<Texture>::GetResource(string(sTextureName));

	sq_pushfloat			(v, pTexture->GetUOffset());

	return 1;
}

SQInteger s_Graphics_Texture_GetVOffset (HSQUIRRELVM v)
{
	const SQChar			*sTextureName;

	sq_getstring			(v, 2, &sTextureName);

	Texture *pTexture = ResourceManager<Texture>::GetResource(string(sTextureName));

	sq_pushfloat			(v, pTexture->GetVOffset());

	return 1;
}